﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace ActiveStory.DataManager
{
    public class SortedPageObservableCollection : ObservableCollection<ActiveStoryPageMetadata>
    {
        public void Sort()
        {
            IList<ActiveStoryPageMetadata> list = this.Items;
            Array.Sort<ActiveStoryPageMetadata>(list.ToArray<ActiveStoryPageMetadata>(), new Comparison<ActiveStoryPageMetadata>(CompareActiveStoryPageMetadata));
        }
        public int CompareActiveStoryPageMetadata(ActiveStoryPageMetadata first, ActiveStoryPageMetadata second)
        {
            if (first.PageNumber < second.PageNumber)
                return -1;
            else if (first.PageNumber > second.PageNumber)
                return 1;
            else
                return 0;
        }
    }
}
